package com.mz.ozy.mvp.presenter;


import android.app.Activity;

import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.bean.LockInfoBean;
import com.mz.ozy.mvp.model.LockWareModel;
import com.mz.ozy.mvp.view.LockWareContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.utils.RxUtil;

import org.json.JSONObject;

import okhttp3.ResponseBody;

/**
 * Created by administrator on 2018/12/3.
 */
public class LockWarePresenter extends BasePresenterImpl<LockWareContract.View> implements LockWareContract.Presenter {

    private LockWareModel mModel;

    public LockWarePresenter() {
        mModel = new LockWareModel();
    }

    @Override
    public void getStorageInfo(Activity activity) {
        mModel.getStorageInfo(activity)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<LockInfoBean>(mView) {
                    @Override
                    public void onSuccesss(LockInfoBean bean) {
                        mView.getStorageInfoSuccess(bean);
                    }
                });
    }

    @Override
    public void confirmStore(Activity activity, String amt, int dayid, String password) {
        mModel.confirmStore(activity, amt, dayid, password)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<JSONObject>(mView) {
                    @Override
                    public void onSuccesss(JSONObject bean) {
                        mView.confirmStoreSuccess(bean);
                    }
                });
    }
}
